package com.mcgrobot.plugin.dynamicds;

import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

public class DynamicDataSource extends AbstractRoutingDataSource {

    @Override
    protected Object determineCurrentLookupKey() {
        String key = DataSourceRouteHolder.getDataSourceKey();
        if(StringUtils.isBlank(key)) {
            return DataSourceRouteHolder.master;
        }else{
            return key;
        }
    }
}
